/*
 * Copyright (C), 2014-2015, 杭州小卡科技有限公司
 * Created by ciwei@xiaokakeji.com on 2016/06/25.
 */
package com.micromall.task;

import com.micromall.repository.OrderMapper;
import com.micromall.service.TransactionalExecuteService;
import com.micromall.utils.CommonEnvConstants;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.Date;

/**
 * @author ciwei@xiaokakeji.com
 * @date 2016/06/25.
 */
@Component
public class AutoConfirmDeliveryTask {

	private static Logger logger = LoggerFactory.getLogger(AutoConfirmDeliveryTask.class);
	@Resource
	private OrderMapper                 orderMapper;
	@Resource
	private TransactionalExecuteService transactionalExecuteService;

	@Scheduled(cron = "0 0/5 * * * ?")
	public void execute() {
		transactionalExecuteService.execute(() -> logger
				.info("自动收货超时未确认收货订单 {} 条", orderMapper.ordersAutoConfirmDelivery(CommonEnvConstants.ORDER_AUTO_CONFIRM_DELIVERY_TIME, new Date())));

	}
}
